Repository navigation
Fix user group reads failing when a member's stored role is None or Tenant Admin - #2100
Merged
Merged
Conversation
…role UserGroupMember refuses the roles NONE and TENANT_ADMIN, which is right for members a caller builds. The same check also ran when the SDK built members from a server response, so one stored member with such a role made UserGroup.get_user_groups(), get(), list_members() and the reads at the end of create() and update() raise ValueError. Members read from the server are now built without the role check and keep the role stored for them. Building a member with one of these roles is still refused. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Contributor
Author
|
CI note: the failing jobs ("Integration Testing" and "Unit && Data Testing" on every Python version) all fail the same way, with |
mnoszczak
marked this pull request as ready for review
November 25, 2026 08:09
mnoszczak
requested review from
KeshavSahoo,
cyrusj89,
gmadaan-hue,
jakefleming,
john-labelbox,
ramy1951 and
rma-eng-bot
November 25, 2026 08:09
pawelkozik-labelbox
approved these changes
Nov 25, 2026
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Before: reading user groups failed when a group had a member whose stored role is None or Tenant Admin.
UserGroup.get_user_groups(),UserGroup.get(),UserGroup.list_members()and the reads at the end ofcreate()andupdate()raised:One such member was enough to stop a workspace from listing any of its groups.
Now: these calls return the group, and the member comes back with the role stored for it.
Why it happened:
UserGroupMember.__post_init__refuses the rolesNONEandTENANT_ADMIN. That check is meant for members a caller builds before adding them to a group. The SDK also ran it when it built members from a server response inUserGroup._get_members_set, so data that already exists on the server made every read fail.The fix: members read from the server are built through a new private
UserGroupMember._from_server(), which skips the role check and keeps the stored role. Nothing changes in the public API.What stays the same:
UserGroupMember(user=..., role=...)still raisesValueErrorforNONEandTENANT_ADMIN. The existing tests for this are unchanged and pass.UserGroupMember(user=other, role=stored_member.role)anddataclasses.replace(...)both run the check).update()replaces the whole member list. Afterget()thenupdate(), the stored member is sent back with the same role id, so saving a group you read does not drop or change that member. Before this fix that round trip could not happen, becauseget()raised.Other code that uses a member's role:
update(),create()andadd_members()only passmember.role.uidto the server, and__hash__/__eq__compare ids. None of them assume the role is assignable, so they work with a stored member as they do with any other.Tests
New unit tests in
libs/labelbox/tests/unit/schema/test_user_group.py, each run for a stored role of None and of Tenant Admin (10 cases):get_user_groups()returns both groups and the member with its stored role.get()returns the member with its stored role.list_members()returns the member with its stored role.get()thenupdate()sends the member back with its stored role, and the read at the end ofupdate()returns it.Results:
10 failed, 26 passedintest_user_group.py. Every failure is theValueErrorabove.36 passedintest_user_group.py; full unit suite (pytest tests/unit)510 passed.mypy src: no issues.ruff format --checkandruff checkon the changed files: clean.Integration tests were not run locally (they need an API key); CI runs them.
Suggested changelog line for the next release
Type of change
All Submissions
Changes to Core Features
🤖 Generated with Claude Code